<?php
namespace Admin\Controller;
//use Think\Controller;
class ObjectController extends CommontController {
    //案例项目添加
    public function add(){
        //实现案例项目添加完成
        $objectModel=D("Object");
        if(IS_POST){
            if($objectModel->create()){
                if($objectModel->add()){
                    $this->success("添加成功",U("Object/index"));die;
                }else{
                    $this->error("添加失败".$objectModel->getError());
                }
            }else{
                $this->error($objectModel->getError());
            }
        }
        //渲染模板
        $this->display();
    }
    //案例项目列表
    public function index(){
        $objectModel=D("Object");
        $list=$objectModel->select();
        $this->assign('list',$list);
        $this->display();
    }
    //案例项目修改
    public function upd(){
        $objectModel=D("Object");
        //案例项目修改完成
        if(IS_POST){
            if($objectModel->create()){
                if($objectModel->save()!==false){
                    $this->success("修改成功",U("Object/index"));die;
                }else{
                    $this->error("修改失败");
                }
            }else{
                $this->error($objectModel->getError());
            }
        }
        //案例项目回显
        $object_id=I('get.object_id');
        $list=$objectModel->find($object_id);
        $this->assign('list',$list);
        $this->display();  
    }
    //案例项目删除
    public function del(){
        $objectModel=D("Object");
        $object_id=I('get.object_id');
        $data=$objectModel->delete($object_id);
        if($data){
            $this->success("删除成功",U('Object/index'));die;
        }else{
            $this->error("删除失败");
        }
    }
    
}